const express = require("express")
const axios = require("axios")
const app = express()
const port = 5001


/*
  请求地址： http://localhost:3000/search/users?q=aa

  后台路由
    key： /search/users
    value： function () {}
*/

app.use((req, res, next)=>{
  console.log("有人请求服务器了！")
  next()
})


app.get('/students', (req, res)=>{
  const students = [
    {id: '001', name:"张三", age: 18},
    {id: '002', name:"李四", age: 19},
    {id: '003', name:"王麻子", age: 20},
    {id: '004', name:"赵丽", age: 21},
  ]
  res.send(students)
})


app.listen(port, "localhost", (err) => {
  if (!err){
  	console.log("服务器启动成功")
  	console.log(`请求github真实数据请访问：http://localhost:${port}/students`)
  } 
  else console.log(err);
})
